import { IDeptVO, deptTree } from '@/api/admin/dept';
import { ref } from 'vue';

export function useDept() {
	const deptList = ref<IDeptVO[]>([]);
	const deptLoading = ref(false);

	async function fetchDept() {
		deptLoading.value = true;
		const res = await deptTree();
		const allDept = {
			id: '',
			name: '全部',
		} as IDeptVO;
		deptList.value = [allDept, ...res.data];
		deptLoading.value = false;
	}

	return {
		deptList,
		deptLoading,
		fetchDept,
	};
}
